export default class QryEntryAction {
    constructor(comp) {
        this.comp = comp;
    }

    //联查入职单
    qryEntry = async (selectedRows) => {
        const {props} = this.comp;
        const {dispatch} = props;
      
        try {
            let entryData = await this.getEntryData(selectedRows);
            if(entryData) {
                dispatch({
                    type: 'emp/update',
                    payload: {
                        addPageDisp: 'none',
                        qryEntryDisp: 'block',
                        addBtnDisp: 'none'
                    }
                });
            }
            let headData = entryData.data.head
            let data = headData.card? headData.card: headData.list
            this.toBrowseStatus(data);
           
        }
        catch(e) {
        }
    }

    // 获取一条数据
    getEntryData = async (selectedRows) => {
        const {props} = this.comp;
        const {dispatch, emp} = props;

        let postData = {
            billid: selectedRows[0].values['pk_entryapply'].value,
            pk_org: emp.orgValue.refpk,
            appcode:'60092010'
        };

        try {
            let res = await dispatch({
                type: 'emp/getEntryData',
                payload: {
                    postData: postData
                }
            });

            if(res.success) {
                return res;
            }
        }
        catch(e) {
        }

        return false;
    }


    // 表单进入浏览态 默认为浏览态  这里只设置值
    toBrowseStatus = (formValue) => {
        const {props} = this.comp;
        const {form} = props;

        // 填充表单的值
        if(formValue) {
            form.setAllFormValue({
                cardItem: formValue
            });
        }

        // 展开子表
        form.openArea('psninf'); 
        form.openArea('tailinfo');
        form.openArea('auditinfo');
    } 

}



 
 
   

   

